<?php

namespace App\Models;

use App\Constant;
use Illuminate\Database\Eloquent\Model;

class SellerWithdrawRequest extends Model
{
    protected $guarded = ['id'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }
    public function seller()
    {
        return $this->belongsTo(Seller::class, 'user_id', 'user_id');
    }
    
    public function payment()
    {
        return $this->hasOne(Payment::class, 'withdraw_request_id', 'id')->where('status', Constant::YES);
    }

    public function latest_payment()
    {
        return $this->hasOne(Payment::class, 'withdraw_request_id', 'id')->where('status', Constant::NO)->orderBy('id', 'desc');
    }
}
